﻿using Basic.Base.Serialization;
using Microsoft.Extensions.DependencyInjection;

namespace System
{
    public static class SerializationExtension
    {
        public static IServiceCollection RegisterSerialization(this IServiceCollection services, string serializationType)
        {
            serializationType = serializationType.ToLower();
            return serializationType switch
            {
                SerializerConst.Json => services.AddTransient<ISerializer, DefaultJsonSerializer>(),
                SerializerConst.Protobuf => services.AddTransient<ISerializer, DefaultProtobufSerializer>(),
                SerializerConst.MessagePack => services.AddTransient<ISerializer, DefaultMessagePackSerializer>(),
                SerializerConst.MemoryPack => services.AddTransient<ISerializer, DefaultMemoryPackSerializer>(),
                _ => services.AddTransient<ISerializer, DefaultJsonSerializer>()
            };
        }

    }
}